package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ModuleEngSerial;
import com.ruoyi.system.service.IModuleEngSerialService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工程识别号Controller
 * 
 * @author jiang
 * @date 2023-09-04
 */
@RestController
@RequestMapping("/system/serial")
public class ModuleEngSerialController extends BaseController {
    @Autowired
    private IModuleEngSerialService moduleEngSerialService;

    /**
     * 查询工程识别号列表
     */
    // @PreAuthorize("@ss.hasPermi('system:serial:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModuleEngSerial moduleEngSerial) {
        startPage();
        List<ModuleEngSerial> list = moduleEngSerialService.selectModuleEngSerialList(moduleEngSerial);
        return getDataTable(list);
    }

    /**
     * 导出工程识别号列表
     */
    // @PreAuthorize("@ss.hasPermi('system:serial:export')")
    @Log(title = "工程识别号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModuleEngSerial moduleEngSerial) {
        List<ModuleEngSerial> list = moduleEngSerialService.selectModuleEngSerialList(moduleEngSerial);
        ExcelUtil<ModuleEngSerial> util = new ExcelUtil<ModuleEngSerial>(ModuleEngSerial.class);
        util.exportExcel(response, list, "工程识别号数据");
    }

    /**
     * 获取工程识别号详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:serial:query')")
    @GetMapping(value = "/{engId}")
    public AjaxResult getInfo(@PathVariable("engId") Long engId) {
        return success(moduleEngSerialService.selectModuleEngSerialByEngId(engId));
    }

    /**
     * 新增工程识别号
     */
    // @PreAuthorize("@ss.hasPermi('system:serial:add')")
    @Log(title = "工程识别号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModuleEngSerial moduleEngSerial) {
        return toAjax(moduleEngSerialService.insertModuleEngSerial(moduleEngSerial));
    }

    /**
     * 修改工程识别号
     */
    // @PreAuthorize("@ss.hasPermi('system:serial:edit')")
    @Log(title = "工程识别号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModuleEngSerial moduleEngSerial) {
        return toAjax(moduleEngSerialService.updateModuleEngSerial(moduleEngSerial));
    }

    /**
     * 删除工程识别号
     */
    // @PreAuthorize("@ss.hasPermi('system:serial:remove')")
    @Log(title = "工程识别号", businessType = BusinessType.DELETE)
    @DeleteMapping("/{engIds}")
    public AjaxResult remove(@PathVariable Long[] engIds) {
        return toAjax(moduleEngSerialService.deleteModuleEngSerialByEngIds(engIds));
    }
}
